package com.ruoyi.gaokao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.gaokao.domain.GkCandidateType;
import com.ruoyi.gaokao.service.IGkCandidateTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 考生类型编码Controller
 * 
 * @author xiaosong
 * @date 2025-07-07
 */
@Api(tags = "高考-考生类型管理")
@RestController
@RequestMapping("/gaokao/CandidateType")
public class GkCandidateTypeController extends BaseController
{
    @Autowired
    private IGkCandidateTypeService gkCandidateTypeService;

    /**
     * 查询考生类型编码列表
     */
    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:list')")
    @GetMapping("/list")
        @ApiOperation("高考考生类型管理 - 分页查询列表")
    public TableDataInfo list(GkCandidateType gkCandidateType)
    {
        startPage();
        List<GkCandidateType> list = gkCandidateTypeService.selectGkCandidateTypeList(gkCandidateType);
        return getDataTable(list);
    }

    // 查询全部数据
    @GetMapping("/all")
        @ApiOperation("高考考生类型管理 - 查询所有数据")
    public AjaxResult getAll(){
        return success(gkCandidateTypeService.selectGkCandidateTypeAll());
    }

    /**
     * 导出考生类型编码列表
     */
    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:export')")
    @Log(title = "考生类型编码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
        @ApiOperation("高考考生类型管理 - 导出数据")
    public void export(HttpServletResponse response, GkCandidateType gkCandidateType)
    {
        List<GkCandidateType> list = gkCandidateTypeService.selectGkCandidateTypeList(gkCandidateType);
        ExcelUtil<GkCandidateType> util = new ExcelUtil<GkCandidateType>(GkCandidateType.class);
        util.exportExcel(response, list, "考生类型编码数据");
    }

    /**
     * 获取考生类型编码详细信息
     */
//    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:query')")
    @GetMapping(value = "/{code}")
        @ApiOperation("高考考生类型管理 - 根据ID获取详细信息")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(gkCandidateTypeService.selectGkCandidateTypeByCode(code));
    }

    /**
     * 新增考生类型编码
     */
    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:add')")
    @Log(title = "考生类型编码", businessType = BusinessType.INSERT)
    @PostMapping
        @ApiOperation("高考考生类型管理 - 新增数据")
    public AjaxResult add(@RequestBody GkCandidateType gkCandidateType)
    {
        return toAjax(gkCandidateTypeService.insertGkCandidateType(gkCandidateType));
    }

    /**
     * 修改考生类型编码
     */
    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:edit')")
    @Log(title = "考生类型编码", businessType = BusinessType.UPDATE)
    @PutMapping
        @ApiOperation("高考考生类型管理 - 修改数据")
    public AjaxResult edit(@RequestBody GkCandidateType gkCandidateType)
    {
        return toAjax(gkCandidateTypeService.updateGkCandidateType(gkCandidateType));
    }

    /**
     * 删除考生类型编码
     */
    @PreAuthorize("@ss.hasPermi('gaokao:CandidateType:remove')")
    @Log(title = "考生类型编码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
        @ApiOperation("高考考生类型管理 - 删除数据")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(gkCandidateTypeService.deleteGkCandidateTypeByCodes(codes));
    }
}
